package uk.org.brindy.osgibb.svnrev.svnkit;

import java.io.File;

import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNStatus;

import uk.org.brindy.osgibb.OSGiBundleBuilderException;
import uk.org.brindy.osgibb.SubversionRevisionProvider;

public class SVNKitSubversionRevisionProvider implements
		SubversionRevisionProvider {

	public long getRevision(File path) throws OSGiBundleBuilderException {
		SVNClientManager mgr = SVNClientManager.newInstance();
		try {
			SVNStatus status = mgr.getStatusClient().doStatus(path, false);
			return status.getRevision().getNumber();
		} catch (SVNException ex) {
			throw new OSGiBundleBuilderException(ex);
		} finally {
			mgr.dispose();
		}
	}

}
